# 精度数据（%）
methods = ['FedAvg', 'FedProx', 'FedAT', 'DHA-FL(ours)', 'DHA-FL-w/o-Layer', 'DHA-FL-w/o-Att']
accuracy = [78.3, 81.5, 82.6, 85.8, 83.0, 81.9]
colors = ['#8ECFC9', '#FFBE7A', '#FA7F6F', '#82B0D2', '#BEB8DC', '#E7DAD2']

# 绘制柱状图
plt.figure(figsize=(10, 6))
bars = plt.bar(methods, accuracy, color=colors, edgecolor='black')

# 添加数据标签
for bar in bars:
    height = bar.get_height()
    plt.text(bar.get_x() + bar.get_width()/2, height+0.5, 
             f'{height}%', ha='center', fontsize=12)

# 标注优化幅度
# plt.annotate('↑7.44%', xy=(3,85.8), xytext=(3,88), 
#              arrowprops=dict(arrowstyle='->', color='black'), ha='center')
# plt.annotate('↑4.21%', xy=(3,85.8), xytext=(3,86.5), 
#              arrowprops=dict(arrowstyle='->', color='black'), ha='center')

plt.ylabel('Accuracy (%)', fontsize=14)
plt.xlabel('method', fontsize=14)
plt.ylim(75, 90)
# plt.title('Model Accuracy Comparison on CIFAR-10 (Non-IID)', fontsize=14)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.savefig('accuracy_comparison_en.png', bbox_inches='tight')
